# encoding: utf-8
class OsseanRanksController < ApplicationController

  def show
    per_page_option = 10
    
    type = params[:type]
    puts type
    @ossean_rank_results_count = OsseanRank.where(:rank_type => type).count
    @ossean_rank_results_pages = Paginator.new @ossean_rank_results_count, per_page_option, params['page']
    @ossean_rank_results = OsseanRank.where(:rank_type => type).order("rank asc").offset(@ossean_rank_results_pages.offset).limit(@ossean_rank_results_pages.per_page)
    
    # 读出所有指标
    @projects = []
    @metrics = []
    puts @ossean_rank_results.size
    @ossean_rank_results.each do |item|
      ossean_id = item.ossean_id
      @metrics << OsseanMetricZscore.find(ossean_id)
      @projects << OpenSourceProject.find(ossean_id)
    end
    
    # 取出所有的标签
    @related_tags = OsseanTypeTag.where(:rank_type => type).order("nums desc")
    
    @rank_type = type.split(" ").map{|o| o.capitalize!}.join(" ")
    
    respond_to do |format|
      format.html
      # {
        # render :layout => "base_opensource_p_1"
      # }
    end
  end
end
